bitkeeper revision 1.250 (3ed5f36fGoVK0VfvAjIbpFZ61R_U0A)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 29 May 2003 11:47:59 +0000 (11:47 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 29 May 2003 11:47:59 +0000 (11:47 +0000)
desc.h, domain.c, mm.c:
  Fix start-of-day callback selectors so that they are not 0 -- this confuses some tests in entry.S.

xen/arch/i386/mm.c
xen/common/domain.c
xen/include/asm-i386/desc.h

index 239aad1bbedaa48a6e7feeccfd538cb958e15de6..7bccd34f9c086e578f12eab4fa043706e5aa1299 100644 (file)
@@ -103,8 +103,8 @@ long do_stack_switch(unsigned long ss, unsigned long esp)
     int nr = smp_processor_id();
     struct tss_struct *t = &init_tss[nr];
 
-    if ( (ss == __HYPERVISOR_CS) || (ss == __HYPERVISOR_DS) )
-        return -1;
+    if ( !VALID_DATASEL(ss) )
+        return -EINVAL;
 
     current->thread.ss1  = ss;
     current->thread.esp1 = esp;
index 7938c2734b4fb10fdb802a25435dfb0fed71ef48..19c26f986cc18faaa6f1816ffad253aa5c03cd55 100644 (file)
@@ -34,7 +34,7 @@ struct task_struct *task_hash[TASK_HASH_SIZE];
  */
 struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu)
 {
-    int retval;
+    int retval, i;
     struct task_struct *p = NULL;
     unsigned long flags;
 
@@ -68,6 +68,15 @@ struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu)
     p->addr_limit = USER_DS;
     p->active_mm  = &p->mm;
 
+    /*
+     * We're basically forcing default RPLs to 1, so that our "what privilege
+     * level are we returning to?" logic works.
+     */
+    p->failsafe_selector = FLAT_RING1_CS;
+    p->event_selector    = FLAT_RING1_CS;
+    p->thread.ss1        = FLAT_RING1_DS;
+    for ( i = 0; i < 256; i++ ) p->thread.traps[i].cs = FLAT_RING1_CS;
+
     sched_add_domain(p);
 
     INIT_LIST_HEAD(&p->pg_head);
index 6fc0cb7182cdcb996e243e3a50aa50198b600634..3155af3268b697b5c0006dcb249b053673ddabeb 100644 (file)
 
 #define load_TR(n)  __asm__ __volatile__ ("ltr  %%ax" : : "a" (__TSS(n)<<3) )
 
-/* Guest OS must provide its own code selectors, or use the one we provide. */
-#define VALID_CODESEL(_s) \
-    ((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_CS))
+/*
+ * Guest OS must provide its own code selectors, or use the one we provide.
+ * The RPL must be 1, as we only create bounce frames to ring 1.
+ */
+#define VALID_CODESEL(_s)                                                  \
+    (((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_CS)) && \
+     (((_s)&3) == 1))
+
+#define VALID_DATASEL(_s)                                                  \
+    (((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_DS)) && \
+     (((_s)&3) == 1))
 
 /* These are bitmasks for the first 32 bits of a descriptor table entry. */
 #define _SEGMENT_TYPE    (15<< 8)